<div class="layui-fluid" id="VIEW-list-table" lay-title="在线用户">
    <div class="layui-row layui-col-space12">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body nepadmin-table-full">
                    <div class="layui-btn-container nepadmin-pad-t10 nepadmin-pad-l10">
                        <div class="layui-btn layui-btn-sm"
                             lay-popup="{url:'/sys/user/sysUserEdit',area:['650px', '450px']}">添加用户
                        </div>
                    </div>
                    <table id="list-table-online" lay-filter="list-table-online"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['admin', 'table', 'form', 'dropdown', 'jquery'], function (admin, table, form, dropdown, $) {
        var view = $('#VIEW-list-table');
        var tableFilter = 'list-table-online';
        table.render({
            elem: '[lay-filter="' + tableFilter + '"]',
            //api: 'getGoods',
            url: '/sysUser/online?token=' + admin.loginToken,
            height: 'full-165',
            cols: [[
                {title: '', type: 'checkbox', fixed: true, width: 60},
                {title: '用户名', field: 'username', minWidth: 300},
                {title: 'IP地址', field: 'ipaddr'},
                {
                    title: '最后访问时间', field: 'lastAccessTime', align: 'center', minWidth: 250, templet: function (d) {
                    var lastAccessTime = layui.util.toDateString(d.lastAccessTime, 'yyyy-MM-dd HH:mm:ss')
                    return '<p><span title="' + d.lastAccessTime + '" class="nepadmin-c-gray">' + lastAccessTime + '</span></p>';
                }
                }
            ]]
        });

        table.on('tool(' + tableFilter + ')', function (obj) {
            if (obj.event === 'del') {//删除行

            } else if (obj.event === "edit") {
                admin.popup({
                        url: '/sys/user/sysUserEdit',
                        area: ['650px', '450px']
                    }
                )
                return false
            }
        });

        dropdown.render({
            elem: view.find('.action-more'),
            click: function (name) {
                console.log('点击了 ' + name);
            },
            options: [{
                name: 'action1',
                title: '更多操作'
            }, {
                name: 'action2',
                title: '更多操作'
            }]
        });
        view.find('.table-action').click(function () {
            var checkedCount = table_1.checkStatus(tableFilter).data.length;
            if (checkedCount == 0) {
                layer.msg('请先选择某行');
            } else {
                layer.msg($(this).html() + checkedCount + '项');
            }
        })
    })
</script>